package com.itouch.bracelet.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itouch.bracelet.R;
import com.itouch.bracelet.bean.Knowledge;
import com.itouch.bracelet.bean.RGroup;


public class KnowledgeAdapter extends BaseAdapter {

	private List<Knowledge> list;
	private LayoutInflater mInflater;
	private Context context;
	
	
	public KnowledgeAdapter(Context context, List<Knowledge> list) {
		this.list= list;
		this.context=context;
		this.mInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Knowledge getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		HoldView mHoldView = null;
		if (view == null) {
			mHoldView = new HoldView();
			view = mInflater.inflate(R.layout.adapter_item_knowledge,
					null);
			mHoldView.k_title = (TextView) view
					.findViewById(R.id.k_title);
			view.setTag(mHoldView);
		} else {
			mHoldView = (HoldView) view.getTag();
		}
		final Knowledge a = list.get(position);
		mHoldView.k_title .setText(a.getTitle());
		return view;
	}

	class HoldView {
		public TextView k_title ;
	}
}
